package com.weetop.akly.presenter;

import android.app.Activity;

import com.weetop.akly.base.mvp.BaseModel;
import com.weetop.akly.base.mvp.BaseObserver;
import com.weetop.akly.base.mvp.BasePresenter;
import com.weetop.akly.bean.TrainItem;
import com.weetop.akly.bean.VoteItem;
import com.weetop.akly.view.TrainListView;

import java.util.ArrayList;
import java.util.Map;

public class TrainListPresent extends BasePresenter<TrainListView> {
    public TrainListPresent(TrainListView baseView, Activity activity) {
        super(baseView, activity);
    }

    /**
     * 获取投票列表
     */
    public void getTrainList(String page) {
        addDisposable(apiServer.getTrainList(page), new BaseObserver<BaseModel<ArrayList<TrainItem>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<ArrayList<TrainItem>> o) {
                baseView.getTrainListSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }
    /**
     * 进行签到操作
     */
    public void doTrainSign(String sn,String code) {
        addDisposable(apiServer.doTrainSign(sn,code), new BaseObserver<BaseModel<Boolean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<Boolean> o) {
                baseView.doTrainSignSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

}
